package com.example.codingchallenge;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.ArrayList;

import com.att.intern.webservice.Incident;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;

public class AddIncident extends Activity {

	private EditText glcET;
	private EditText stateET;
	private EditText pmET;
	private EditText buildingNameET;
	private EditText addressET;
	private Spinner eventYearSP;
	private EditText requestorUserIdET;
	private EditText contactNumberET;
	private EditText initialReportDateET;
	private Spinner eventSP;
	private Spinner propertyTypeSP;
	private EditText workRequestNumberET;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_add_incident);
	
		glcET = (EditText) findViewById(R.id.glcEditText);
		stateET = (EditText) findViewById(R.id.stateEditText);
		pmET = (EditText) findViewById(R.id.pmEditText);
		buildingNameET = (EditText) findViewById(R.id.buildingNameEditText);
		addressET = (EditText) findViewById(R.id.addressEditText);
		eventYearSP = (Spinner) findViewById(R.id.eventYearSpinner);
		requestorUserIdET = (EditText) findViewById(R.id.requestorUserIdEditText);
		contactNumberET = (EditText) findViewById(R.id.contactNumberEditText);
		initialReportDateET = (EditText) findViewById(R.id.initialReportDateEditText);
		eventSP = (Spinner) findViewById(R.id.eventSpinner);
		propertyTypeSP = (Spinner) findViewById(R.id.propertyTypeSpinner);
		workRequestNumberET = (EditText) findViewById(R.id.workRequestNumberEditText);
		
		/*Intent intent = getIntent();
		Incident incident = (Incident) intent.getSerializableExtra("incident");
		
		glcET.setText(incident.getGeoLoc() + "");
		stateET.setText(incident.getState());
		pmET.setText(incident.getPMAttuid());
		buildingNameET.setText(incident.getBuildingName());
		addressET.setText(incident.getBuildingAddress());*/
		
		// TODO eventYearSP
		ArrayList<String> years = new ArrayList<String>();
		years.add("2013");
		years.add("2012");
		years.add("2011");
		years.add("2010");
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, years);
		eventYearSP.setAdapter(adapter);
				
		//requestorUserIdET.setText(incident.getReqATTUID());
		
		// Editable = N
		glcET.setFocusable(false);
		stateET.setFocusable(false);
		pmET.setFocusable(false);
		buildingNameET.setFocusable(false);
		addressET.setFocusable(false);
		
		// Editable = Y
		DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
		Date date = new Date();
		initialReportDateET.setText(dateFormat.format(date)); // CURRENT DATE
		
		
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.add_incident, menu);
		return true;
	}

}
